package com.hbu.product.hbumallproduct.utils;

import java.sql.Connection;

/**
 * @ProjectName: hbu-mall
 * @Package: com.hbu.product.hbumallproduct.utils
 * @ClassName: ConnectionContext
 * @Author: zxh
 * @Description:
 * @Date: 2022/11/18 13:52
 * @Version: 1.0
 */
public class ConnectionContext {

    private static final ThreadLocal<Connection> CONNECTION_THREAD_LOCAL = new ThreadLocal<>();

    public static void setConnection(Connection connection){
        CONNECTION_THREAD_LOCAL.set(connection);
    }

    public static Connection getConnection(){
        return CONNECTION_THREAD_LOCAL.get();
    }

    public static void clear(){
        CONNECTION_THREAD_LOCAL.remove();
    }

}
